package rmiclient;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import rmiserver.service.RMIService;

public class RMIClient {
	private RMIService service;

	public RMIClient() {
		String s = "//127.0.1.1/rmiExample";
		try {
			Registry registry = LocateRegistry.getRegistry(1234);
			service = (RMIService) registry.lookup(s);
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		RMIClient rmiClient = new RMIClient();
		rmiClient.init();
	}

	private void init() {
		try {
			LoginFrame login = new LoginFrame();
			login.setService(service);
			login.connect();
			login.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
